package com.openrange.dukes
{
	import org.flixel.*;
	
	public class GUI 
	{
		
		[Embed(source = "../../../../assets/overmap_hud_back.png")] static public var backgroundImage:Class;
		[Embed(source = "../../../../assets/TheReconLegendFont.ttf", fontFamily = "legend", embedAsCFF = "false")] protected var junk:String;
		
		
		protected var _background:FlxSprite;
		
		protected var _dukeNameText:FlxText;
		protected var _turnText:FlxText;
		protected var _scoreText:FlxText;
		
		protected var _forcesStaticText:FlxText;
		
		protected var _terrainStaticText:FlxText;
		protected var _terrainTypeText:FlxText;
		protected var _terrainDetailsText:FlxText;
		
		
		public function GUI(fs:FlxState, map:Terrain) 
		{
			_background = new FlxSprite(0, 0, backgroundImage);
			fs.add(_background);
		
			var border:int = 10;
			var leftPos:int = map.mapWidth + map.offsetX + border;
			var rightPos:int = FlxG.width - leftPos - border;
			
			//____________
			var dukeNameSize:int = 40;
			_dukeNameText = new FlxText(leftPos, border, rightPos, "Duke Archiband", true);
			_dukeNameText.setFormat("legend", dukeNameSize, 0xECC8EC, "right", 0);
			fs.add(_dukeNameText);
			
			var turnSize:int = 25;
			_turnText = new FlxText(leftPos, _dukeNameText.y+dukeNameSize, rightPos, "Turn 1", true);
			_turnText.setFormat("legend", turnSize, 0xFFFFFF, "right", 0);
			fs.add(_turnText);
			
			var scoreTextSize:int = 25;
			_scoreText = new FlxText(leftPos, _turnText.y+turnSize, rightPos, "Score : 20", true);
			_scoreText.setFormat("legend", turnSize, 0xFFFFFF, "right", 0);
			fs.add(_scoreText);
			
			//____________
			var forcesSize:int = 40;
			_forcesStaticText = new FlxText(leftPos, 205-forcesSize, rightPos, "FORCES", true);
			_forcesStaticText.setFormat("legend", forcesSize, 0xFFFFFF, "right", 0);
			fs.add(_forcesStaticText);
			
			//____________
			var terrainSize:int = 40;
			_terrainStaticText = new FlxText(leftPos, 505-terrainSize, rightPos, "TERRAIN", true);
			_terrainStaticText.setFormat("legend", forcesSize, 0xFFFFFF, "right", 0);
			fs.add(_terrainStaticText);
			
			var terrainTypeSize:int = 25;
			_terrainTypeText = new FlxText(leftPos, _terrainStaticText.y+terrainSize + (border*2), rightPos, "Forest", true);
			_terrainTypeText.setFormat("legend", terrainTypeSize, 0xFFFFFF, "right", 0);
			fs.add(_terrainTypeText); 
			
			var terrainDetailsSize:int = 25;
			_terrainDetailsText = new FlxText(leftPos, _terrainTypeText.y+terrainTypeSize, rightPos, "(+1 Defense, -1 Movement)", true);
			_terrainDetailsText.setFormat("legend", terrainDetailsSize, 0xFFFFFF, "right", 0);
			fs.add(_terrainDetailsText); 
		}
		
		public function SetTurn(turnNo:int):void
		{
			_turnText.text = "Turn " + turnNo;
		}
		public function SetTerrain(terrainType:int):void
		{
			_terrainTypeText.text = Tile.getTileNameText(terrainType);
			_terrainDetailsText.text = Tile.getTileEffectText(terrainType);
		}
		
	}

}